package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.SysTask;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SysTaskMapper extends BaseMapper<SysTask> {

    @Select("select * from sys_task where success = 0 and queue_type = 1 and server_key = #{serverKey} and join_time > #{joinTime}")
    public List<SysTask> refreshFastQueue(@Param("serverKey") String serverKey, @Param("joinTime") Long joinTime);

    @Select("select * from sys_task where success = 0 and queue_type = 0 and server_key = #{serverKey} and failures < #{failures} and join_time > #{joinTime}")
    public List<SysTask> refreshErrorQueue(@Param("serverKey") String serverKey,@Param("joinTime") Long joinTime, @Param("failures") int failures);

    @Select("select * from sys_task where success = 0 and failures < #{failures} and server_key = #{serverKey}")
    public List<SysTask> findTaskByOffline(@Param("serverKey") String serverKey, @Param("failures") int failures);

}
